package org.fhm.zdte.common.constant.subcmd;

import org.fhm.zdte.common.standard.ISubCmd;

/**
 * An instruction type enumeration of the sub-instructions of the connection packet.
 *
 * @author 谭波
 * @since 2023/11/24
 */
public enum ConnectCmd implements ISubCmd {

    START_CONNECT((byte) 0b00000001),
    INQUIRIES((byte) 0b00000010),
    CONNECT((byte) 0b00000011);

    private final Byte valueBit;

    ConnectCmd(byte valueBit) {
        this.valueBit = valueBit;
    }

    public static ISubCmd obtainSubCmd(Byte b) {
        for (ConnectCmd value : ConnectCmd.values()) {
            if (value.valueBit.equals(b))
                return value;
        }
        return null;
    }

    @Override
    public byte getFlagOfSubCmd() {
        return valueBit;
    }

}